<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSeriesTable extends Migration
{

    protected $tableName = 'series';

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create($this->tableName, function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->comment('课程名称');
            $table->string('description')->default('')->comment('课程描述');
            $table->unsignedInteger('cover')->comment('封面');
            $table->unsignedSmallInteger('course_count')->comment('课程数');
            $table->unsignedTinyInteger('is_published')->default(0)->comment('是否发布');

            $table->timestamps();
            $table->softDeletes();
        });
        DB::statement("ALTER TABLE `$this->tableName` comment '课程系列'");

        DB::table($this->tableName)->insert([
            'name' => 'TCM系列',
            'description' => '自制绘本',
            'cover'=> '',
            'is_published' => 1
        ]);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists($this->tableName);
    }
}
